/*
 * Copyright 2007 National Bioinformatics Network
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package dgbgui.gui.widgets.visual;

import java.awt.Color;

import dgbgui.gui.widgets.SpacerWidget;
import dgbgui.gui.widgets.Widget;
import dgbgui.gui.widgets.layouts.HorizontalLayout;
import dgbgui.modeldocument.Query;
import edu.umd.cs.piccolo.PNode;



public class TitleBarWidget extends RectangleBorder {
    
    /**
     * Default serial version ID
     */
    private static final long serialVersionUID = 1L;

    public TitleBarWidget(Query query, PNode parent, String title, boolean definitionExpanded, boolean resultExpanded, boolean hasDefinitionWidget, boolean hasResultWidget ) {
        // Top rounded, bottom flat
        super(parent,5.0,0);
        //setGradient(true);
        m_query = query;
        m_layout = new HorizontalLayout(this,5,5);
        new LabelWidget(m_layout,title);
        new SpacerWidget(m_layout);
        
        // The definition min and max, there must always be a definition
        if ( definitionExpanded ) {
            m_definitionMinMaxWidget = new MinimizeWidget(m_layout, hasDefinitionWidget);
        } else {
            m_definitionMinMaxWidget = new MaximizeWidget(m_layout, hasDefinitionWidget);
        }
        
        // The definition min and max, enabled only if there is a result widget
        if ( resultExpanded ) {
            m_resultMinMaxWidget = new MinimizeWidget(m_layout, hasResultWidget);
        } else {
            m_resultMinMaxWidget = new MaximizeWidget(m_layout, hasResultWidget);
        }
        
        setStrokeColor(Color.black);
        setFillColor(new Color(210,210,240));
    }
    
    public Widget getDefinitionMinMaxWidget() {
        return m_definitionMinMaxWidget;
    }
    
    public Query getQuery() {
        return m_query;
    }
    
    Widget m_definitionMinMaxWidget,m_resultMinMaxWidget;
    
    Query m_query;

}
